****************************************************************************
**************** Replication of country-level analysis *********************
* Behind the throne: Regime support coalitions around the world, 1789-2020 *
************* Knutsen, Dahlum, Rasmussen, Wig, 2024 BJPS *******************
****************************************************************************

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year v2svindep_ses country_name v2x_suffr v2reginfo v2regendtype v2regint v2regidnr v2regdur v2regimpgroup v2regimpgroup_nr v2regsupgroupssize v2regsupgroupssize_mean v2regsupgroupssize_nr v2regsuploc v2regsuploc_nr v2regimpoppgroup v2regimpoppgroup_nr v2regoppgroupssize v2regoppgroupssize_mean v2regoppgroupssize_nr v2regopploc v2regopploc_nr v2regproreg v2regproreg_nr v2regantireg v2regantireg_nr v2regpower v2regpower_nr v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regoppgroupsact_nr v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regimpgroup_nr v2regsupgroupssize_codelow v2regsupgroupssize_codehigh v2regsupgroupssize_sd v2regsupgroupssize_nr v2regsuploc_nr v2regimpoppgroup_nr v2regoppgroupssize_codelow v2regoppgroupssize_codehigh v2regoppgroupssize_sd v2regoppgroupssize_nr v2regoppgroups_nr v2regoppgroupsact_nr v2regsupgroups_nr historical lnFarGDPpc nv2clrspct v2x_freexp_altinf democracy63 lexical_index63 anckar_regimenarrowcat anckar_regimebroadcat gwf_regimetype gwf_casename solschdum e_mipopula share_military share_middleclass_occupation share_mid share_low share_bluecollar q1_populationshare_lb s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima v2x_regime lexical_index_plus63 e_regionpol_6C v2x_polyarchy

**************************************************
********** Variable construction *****************
**************************************************
xtset country_id year
sort country_id year


save "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", replace

**generate log reg breakdown in years: 
generate lnHRDduration = ln((v2regdur/365)+1)

*generate breakdown dummy
generate breakdown =. 
replace breakdown = v2regendtype if v2regidnr!= v2regidnr[_n+1]
browse country_name year breakdown v2regendtype v2regidnr v2regdur

generate breakdownyear = .
replace breakdownyear =0 if v2regidnr!=.
replace breakdownyear =1 if breakdown!=.

sort country_id year
by country_id (year): generate last10break = breakdownyear +L.breakdownyear +L2.breakdownyear+L3.breakdownyear+L4.breakdownyear+L5.breakdownyear + L6.breakdownyear +L7.breakdownyear+L8.breakdownyear+L9.breakdownyear    
sort country_id year

*generate coup dummy
generate coupyear = .
replace coupyear =0 if v2regidnr!=.
replace coupyear =1 if breakdown==0 | breakdown==1

*generate mass uprising
generate revoyear = .
replace revoyear =0 if v2regidnr!=.
replace revoyear =1 if breakdown== 8

*generate insurgency
generate insuyear = .
replace insuyear =0 if v2regidnr!=.
replace insuyear =1 if breakdown== 5

*generate war + foreign intervention
generate foreignyear = .
replace  foreignyear =0 if v2regidnr!=.
replace  foreignyear =1 if breakdown==6 | breakdown==7


xtset country_id year
sort country_id year

label variable v2regsupgroups_0 "The Aristocracy"
label variable v2regsupgroups_1 "Agrarian elites"
label variable v2regsupgroups_2 "Party elites"
label variable v2regsupgroups_3 "Business elites"
label variable v2regsupgroups_4 "The state bureacracy"
label variable v2regsupgroups_5 "The military"
label variable v2regsupgroups_6 "Ethnic/racial group"
label variable v2regsupgroups_7 "Religious group"
label variable v2regsupgroups_8 "Local elites"
label variable v2regsupgroups_9 "Urban working classes"
label variable v2regsupgroups_10 "Urban middle classes"
label variable v2regsupgroups_11 "Rural working classes"
label variable v2regsupgroups_12 "Rural middle classes"
label variable v2regsupgroups_13 "Foreign government"



rename v2regsupgroups_nr nr_v2regsuppgroups
rename  v2regoppgroups_nr nr_v2regoppgroups

*Group at least in coalition, dichotomous: support group dummies 
foreach x of varlist v2regsupgroups_* {
   gen `x'_diko = `x'
}

foreach x of varlist v2regsupgroups_0_diko-v2regsupgroups_13_diko {
   replace `x'= 1 if `x' >= 0.5 & `x' !=.
   replace `x'= 0 if `x' < 0.5 & `x' !=.
}

label variable v2regsupgroups_0_diko "The Aristocracy"
label variable v2regsupgroups_1_diko "Agrarian elites"
label variable v2regsupgroups_2_diko "Party elites"
label variable v2regsupgroups_3_diko "Business elites"
label variable v2regsupgroups_4_diko "The state bureacracy"
label variable v2regsupgroups_5_diko "The military"
label variable v2regsupgroups_6_diko "Ethnic/racial group"
label variable v2regsupgroups_7_diko "Religious group"
label variable v2regsupgroups_8_diko "Local elites"
label variable v2regsupgroups_9_diko "Urban working classes"
label variable v2regsupgroups_10_diko "Urban middle classes"
label variable v2regsupgroups_11_diko "Rural working classes"
label variable v2regsupgroups_12_diko "Rural middle classes"
label variable v2regsupgroups_13_diko "Foreign government"

xtset country_id year
sort country_id year

label variable v2regoppgroups_0 "The Aristocracy"
label variable v2regoppgroups_1 "Agrarian elites"
label variable v2regoppgroups_2 "Party elites"
label variable v2regoppgroups_3 "Business elites"
label variable v2regoppgroups_4 "The state bureacracy"
label variable v2regoppgroups_5 "The military"
label variable v2regoppgroups_6 "Ethnic/racial group"
label variable v2regoppgroups_7 "Religious group"
label variable v2regoppgroups_8 "Local elites"
label variable v2regoppgroups_9 "Urban working classes"
label variable v2regoppgroups_10 "Urban middle classes"
label variable v2regoppgroups_11 "Rural working classes"
label variable v2regoppgroups_12 "Rural middle classes"
label variable v2regoppgroups_13 "Foreign government"

*Group at least in coalition, dichotomous:  opposition group dummies
foreach x of varlist v2regoppgroups_* {
   gen `x'_diko = `x'
}

foreach x of varlist v2regoppgroups_0_diko-v2regoppgroups_13_diko {
   replace `x'= 1 if `x' >= 0.5 & `x' !=.
   replace `x'= 0 if `x' < 0.5 & `x' !=.
}

label variable v2regoppgroups_0_diko "The Aristocracy"
label variable v2regoppgroups_1_diko "Agrarian elites"
label variable v2regoppgroups_2_diko "Party elites"
label variable v2regoppgroups_3_diko "Business elites"
label variable v2regoppgroups_4_diko "The state bureacracy"
label variable v2regoppgroups_5_diko "The military"
label variable v2regoppgroups_6_diko "Ethnic/racial group"
label variable v2regoppgroups_7_diko "Religious group"
label variable v2regoppgroups_8_diko "Local elites"
label variable v2regoppgroups_9_diko "Urban working classes"
label variable v2regoppgroups_10_diko "Urban middle classes"
label variable v2regoppgroups_11_diko "Rural working classes"
label variable v2regoppgroups_12_diko "Rural middle classes"
label variable v2regoppgroups_13_diko "Foreign government"

*Number of support groups
capture drop no_groups
gen no_groups = v2regsupgroups_0_diko + v2regsupgroups_1_diko + v2regsupgroups_2_diko + v2regsupgroups_3_diko + v2regsupgroups_4_diko + v2regsupgroups_5_diko + v2regsupgroups_6_diko + v2regsupgroups_7_diko + v2regsupgroups_8_diko + v2regsupgroups_9_diko + v2regsupgroups_10_diko + v2regsupgroups_11_diko + v2regsupgroups_12_diko + v2regsupgroups_13_diko
tab no_groups

*Number of opposition groups
capture drop no_oppgroups
gen no_oppgroups = v2regoppgroups_0_diko + v2regoppgroups_1_diko + v2regoppgroups_2_diko + v2regoppgroups_3_diko + v2regoppgroups_4_diko + v2regoppgroups_5_diko + v2regoppgroups_6_diko + v2regoppgroups_7_diko + v2regoppgroups_8_diko + v2regoppgroups_9_diko + v2regoppgroups_10_diko + v2regoppgroups_11_diko + v2regoppgroups_12_diko + v2regoppgroups_13_diko
tab no_oppgroups


**Generate Geddes et al dummies from Anckar & Fredriksson data

generate sparty = .
replace sparty= 0 if anckar_regimenarrowcat !=.
replace sparty= 1 if anckar_regimenarrowcat ==4

generate personal = .
replace personal= 0 if anckar_regimenarrowcat !=.
replace personal= 1 if anckar_regimenarrowcat ==6

generate military 	= .
replace military= 0 if anckar_regimenarrowcat !=.
replace military= 1 if anckar_regimenarrowcat ==7

generate monarchy	= .
replace monarchy= 0 if anckar_regimenarrowcat !=.
replace monarchy= 1 if anckar_regimenarrowcat ==3			 
replace monarchy= 1 if anckar_regimenarrowcat ==8			 
replace monarchy= 1 if anckar_regimenarrowcat ==9			 

**Generate Gedddes et al regime type dummies from Geddes et al. data (for Appx IV)

generate puremil =.
replace puremil =0 if gwf_regimetype!=""
replace puremil =1 if gwf_regimetype=="military"

generate pureper =.
replace pureper =0 if gwf_regimetype!=""
replace pureper =1 if gwf_regimetype=="personal"

generate purepar =.
replace purepar =0 if gwf_regimetype!=""
replace purepar =1 if gwf_regimetype=="party"

generate puremon =.
replace puremon =0 if gwf_regimetype!=""
replace puremon =1 if gwf_regimetype=="monarchy"

generate pureoli =.
replace pureoli =0 if gwf_regimetype!=""
replace pureoli =1 if gwf_regimetype=="oligarchy"

generate pureimi =.
replace pureimi =0 if gwf_regimetype!=""
replace pureimi =1 if gwf_regimetype=="indirect military"

generate mipe =.
replace mipe =0 if gwf_regimetype!=""
replace mipe =1 if gwf_regimetype=="military-personal"

generate mipepa =.
replace mipepa =0 if gwf_regimetype!=""
replace mipepa =1 if gwf_regimetype=="party-military-personal"

generate mipa =.
replace mipa =0 if gwf_regimetype!=""
replace mipa =1 if gwf_regimetype=="party-military"

generate pepa =.
replace pepa =0 if gwf_regimetype!=""
replace pepa =1 if gwf_regimetype=="party-personal"

generate hybridgwf = mipe + mipepa + mipa + pepa
generate purelimgwf = puremil + purepar + pureper
generate puremaxgwf = puremil + purepar + pureper + puremon + pureimi + pureoli

summarize hybridgwf purelimgwf puremaxgwf, detail


**Size: generating normalized measures, and then squares, for use in Appx II
foreach v of var v2regsupgroupssize v2regoppgroupssize { 
	su `v', meanonly 
	gen n`v' = (`v' - r(min)) / (r(max) - r(min)) 
}	

generate nv2regsupgroupssizesq = nv2regsupgroupssize^2
generate nv2regoppgroupssizesq = nv2regoppgroupssize^2

**generate extrapolated population measure for tests in Appendix II
summarize e_mipopula
*lots of missing, intra and extrapolate
generate lnpop = ln(e_mipopula*1000)
sort country_id year
by country_id, sort : ipolate lnpop year, generate(lnpope) epolate
summarize lnpop lnpope if v2regsupgroupssize!=.
sort country_id year



** Generating support group dummies using alternative thresholds, for Appx VII
***Different thresholds dummies

*Group at least in coalition, dichotomous 
foreach x of varlist v2regsupgroups_* {
   gen `x'_diko40 = `x'
}

foreach x of varlist v2regsupgroups_0_diko40-v2regsupgroups_13_diko40 {
   replace `x'= 1 if `x' >= 0.4 & `x' !=.
   replace `x'= 0 if `x' < 0.4 & `x' !=.
}

label variable v2regsupgroups_0_diko40 "The Aristocracy"
label variable v2regsupgroups_1_diko40 "Agrarian elites"
label variable v2regsupgroups_2_diko40 "Party elites"
label variable v2regsupgroups_3_diko40 "Business elites"
label variable v2regsupgroups_4_diko40 "The state bureacracy"
label variable v2regsupgroups_5_diko40 "The military"
label variable v2regsupgroups_6_diko40 "Ethnic/racial group"
label variable v2regsupgroups_7_diko40 "Religious group"
label variable v2regsupgroups_8_diko40 "Local elites"
label variable v2regsupgroups_9_diko40 "Urban working classes"
label variable v2regsupgroups_10_diko40 "Urban middle classes"
label variable v2regsupgroups_11_diko40 "Rural working classes"
label variable v2regsupgroups_12_diko40 "Rural middle classes"
label variable v2regsupgroups_13_diko40 "Foreign government"

xtset country_id year
sort country_id year

drop *_diko_diko*

foreach x of varlist v2regsupgroups_* {
   gen `x'_diko45 = `x'
}

foreach x of varlist v2regsupgroups_0_diko45-v2regsupgroups_13_diko45 {
   replace `x'= 1 if `x' >= 0.45 & `x' !=.
   replace `x'= 0 if `x' < 0.45 & `x' !=.
}

label variable v2regsupgroups_0_diko45 "The Aristocracy"
label variable v2regsupgroups_1_diko45 "Agrarian elites"
label variable v2regsupgroups_2_diko45 "Party elites"
label variable v2regsupgroups_3_diko45 "Business elites"
label variable v2regsupgroups_4_diko45 "The state bureacracy"
label variable v2regsupgroups_5_diko45 "The military"
label variable v2regsupgroups_6_diko45 "Ethnic/racial group"
label variable v2regsupgroups_7_diko45 "Religious group"
label variable v2regsupgroups_8_diko45 "Local elites"
label variable v2regsupgroups_9_diko45 "Urban working classes"
label variable v2regsupgroups_10_diko45 "Urban middle classes"
label variable v2regsupgroups_11_diko45 "Rural working classes"
label variable v2regsupgroups_12_diko45 "Rural middle classes"
label variable v2regsupgroups_13_diko45 "Foreign government"

xtset country_id year
sort country_id year

drop *_diko_diko*
drop *_diko40_diko*

foreach x of varlist v2regsupgroups_* {
   gen `x'_diko55 = `x'
}

foreach x of varlist v2regsupgroups_0_diko55-v2regsupgroups_13_diko55 {
   replace `x'= 1 if `x' >= 0.55 & `x' !=.
   replace `x'= 0 if `x' < 0.55 & `x' !=.
}

label variable v2regsupgroups_0_diko55 "The Aristocracy"
label variable v2regsupgroups_1_diko55 "Agrarian elites"
label variable v2regsupgroups_2_diko55 "Party elites"
label variable v2regsupgroups_3_diko55 "Business elites"
label variable v2regsupgroups_4_diko55 "The state bureacracy"
label variable v2regsupgroups_5_diko55 "The military"
label variable v2regsupgroups_6_diko55 "Ethnic/racial group"
label variable v2regsupgroups_7_diko55 "Religious group"
label variable v2regsupgroups_8_diko55 "Local elites"
label variable v2regsupgroups_9_diko55 "Urban working classes"
label variable v2regsupgroups_10_diko55 "Urban middle classes"
label variable v2regsupgroups_11_diko55 "Rural working classes"
label variable v2regsupgroups_12_diko55 "Rural middle classes"
label variable v2regsupgroups_13_diko55 "Foreign government"

xtset country_id year
sort country_id year

drop *_diko_diko*
drop *_diko40_diko*
drop *_diko45_diko*


foreach x of varlist v2regsupgroups_* {
   gen `x'_diko60 = `x'
}

foreach x of varlist v2regsupgroups_0_diko60-v2regsupgroups_13_diko60 {
   replace `x'= 1 if `x' >= 0.6 & `x' !=.
   replace `x'= 0 if `x' < 0.6 & `x' !=.
}

label variable v2regsupgroups_0_diko60 "The Aristocracy"
label variable v2regsupgroups_1_diko60 "Agrarian elites"
label variable v2regsupgroups_2_diko60 "Party elites"
label variable v2regsupgroups_3_diko60 "Business elites"
label variable v2regsupgroups_4_diko60 "The state bureacracy"
label variable v2regsupgroups_5_diko60 "The military"
label variable v2regsupgroups_6_diko60 "Ethnic/racial group"
label variable v2regsupgroups_7_diko60 "Religious group"
label variable v2regsupgroups_8_diko60 "Local elites"
label variable v2regsupgroups_9_diko60 "Urban working classes"
label variable v2regsupgroups_10_diko60 "Urban middle classes"
label variable v2regsupgroups_11_diko60 "Rural working classes"
label variable v2regsupgroups_12_diko60 "Rural middle classes"
label variable v2regsupgroups_13_diko60 "Foreign government"

xtset country_id year
sort country_id year

drop *_diko_diko*
drop *_diko40_diko*
drop *_diko45_diko*
drop *_diko55_diko*

gen no_groups40 = v2regsupgroups_0_diko40 + v2regsupgroups_1_diko40 + v2regsupgroups_2_diko40 + v2regsupgroups_3_diko40 + v2regsupgroups_4_diko40 + v2regsupgroups_5_diko40 + v2regsupgroups_6_diko40 + v2regsupgroups_7_diko40 + v2regsupgroups_8_diko40 + v2regsupgroups_9_diko40 + v2regsupgroups_10_diko40 + v2regsupgroups_11_diko40 + v2regsupgroups_12_diko40 + v2regsupgroups_13_diko40

gen no_groups45 = v2regsupgroups_0_diko45 + v2regsupgroups_1_diko45 + v2regsupgroups_2_diko45 + v2regsupgroups_3_diko45 + v2regsupgroups_4_diko45 + v2regsupgroups_5_diko45 + v2regsupgroups_6_diko45 + v2regsupgroups_7_diko45 + v2regsupgroups_8_diko45 + v2regsupgroups_9_diko45 + v2regsupgroups_10_diko45 + v2regsupgroups_11_diko45 + v2regsupgroups_12_diko45 + v2regsupgroups_13_diko45

gen no_groups55 = v2regsupgroups_0_diko55 + v2regsupgroups_1_diko55 + v2regsupgroups_2_diko55 + v2regsupgroups_3_diko55 + v2regsupgroups_4_diko55 + v2regsupgroups_5_diko55 + v2regsupgroups_6_diko55 + v2regsupgroups_7_diko55 + v2regsupgroups_8_diko55 + v2regsupgroups_9_diko55 + v2regsupgroups_10_diko55 + v2regsupgroups_11_diko55 + v2regsupgroups_12_diko55 + v2regsupgroups_13_diko55


gen no_groups60 = v2regsupgroups_0_diko60 + v2regsupgroups_1_diko60 + v2regsupgroups_2_diko60 + v2regsupgroups_3_diko60 + v2regsupgroups_4_diko60 + v2regsupgroups_5_diko60 + v2regsupgroups_6_diko60 + v2regsupgroups_7_diko60 + v2regsupgroups_8_diko60 + v2regsupgroups_9_diko60 + v2regsupgroups_10_diko60 + v2regsupgroups_11_diko60 + v2regsupgroups_12_diko60 + v2regsupgroups_13_diko60

generate v2regsupgroups_nr = nr_v2regsuppgroups
generate  v2regoppgroups_nr = nr_v2regoppgroups

save "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", replace

**************************************************
***** Figures and analysis in the main paper *****
**************************************************

** Figure 1: World Map constructed separately in R

** Figure 2: Convergent validation, Schultz and Kelsall measure
correlate q1_populationshare_lb v2regsupgroupssize

*Year 1960
twoway (scatter q1_populationshare_lb v2regsupgroupssize if year==1960, mcolor(black) msize(vsmall) msymbol(circle) mlabel(country_name) mlabsize(vsmall) mlabcolor(black) mlabposition(12)) (lfit q1_populationshare_lb v2regsupgroupssize if year==1960, lcolor(black)) if year==1960, ytitle(Leader Block % of population) xtitle(Support coalition size) legend(off) graphregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none)) plotregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none))
correlate q1_populationshare_lb v2regsupgroupssize if year==1960
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_1960.gph"

*Year 1980
twoway (scatter q1_populationshare_lb v2regsupgroupssize if year==1980, mcolor(black) msize(vsmall) msymbol(circle) mlabel(country_name) mlabsize(vsmall) mlabcolor(black) mlabposition(12)) (lfit q1_populationshare_lb v2regsupgroupssize if year==1980, lcolor(black)) if year==1980, ytitle(Leader Block % of population) xtitle(Support coalition size) legend(off) graphregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none)) plotregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none))
correlate q1_populationshare_lb v2regsupgroupssize if year==1980
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_1980.gph"
*Year 2000
twoway (scatter q1_populationshare_lb v2regsupgroupssize if year==2000, mcolor(black) msize(vsmall) msymbol(circle) mlabel(country_name) mlabsize(vsmall) mlabcolor(black) mlabposition(12)) (lfit q1_populationshare_lb v2regsupgroupssize if year==2000, lcolor(black)) if year==2000, ytitle(Leader Block % of population) xtitle(Support coalition size) legend(off) graphregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none)) plotregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none))
correlate q1_populationshare_lb v2regsupgroupssize if year==2000
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_2000.gph"

*Year 2018 (last for Schultz & kelsall)
twoway (scatter q1_populationshare_lb v2regsupgroupssize if year==2018, mcolor(black) msize(vsmall) msymbol(circle) mlabel(country_name) mlabsize(vsmall) mlabcolor(black) mlabposition(12)) (lfit q1_populationshare_lb v2regsupgroupssize if year==2018, lcolor(black)) if year==2018, ytitle(Leader Block % of population) xtitle(Support coalition size) legend(off) graphregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none)) plotregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none))
correlate q1_populationshare_lb v2regsupgroupssize if year==2018
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_2018.gph"

graph combine "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_1960.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_1980.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_2000.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\val_a_2018.gph", graphregion(fcolor(white) lwidth(none) ifcolor(white) ilwidth(none))
*title(Measured in 1960 (top-left) 1980 (t-r), 2000 (b-l), 2018 (b-r))


** Figure 3: Kernell density plots size; Democracy vs. Autocracy
twoway (kdensity v2regsupgroupssize if democracy63==0, lcolor(black) lwidth(medium) lpattern(longdash)) (kdensity v2regsupgroupssize if democracy63==1, lcolor(red) lwidth(medium) lpattern(solid)), ytitle(Density) xtitle(Regime support group size) xscale(range(-4 4)) xscale(noextend nofextend) xlabel(-4(2)4) title(Kernell density by regime type (black: autocracy; red:democracy), size(medlarge)) legend(off) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))

graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\sgsize.gph"
graph export "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\sgsize.pdf", as(pdf) name("Graph")


twoway (kdensity v2regoppgroupssize if democracy63==0, lcolor(black) lwidth(medium) lpattern(longdash)) (kdensity v2regoppgroupssize if democracy63==1, lcolor(red) lwidth(medium) lpattern(solid)), ytitle(Density) xtitle(Regime opposition group size) xscale(range(-4 4)) xscale(noextend nofextend) xlabel(-4(2)4) title(Kernell density by regime type (black: autocracy; red:democracy), size(medlarge)) legend(off) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))

graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\ogsize.gph"
graph export "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\ogsize.pdf", as(pdf) 

** Figure 4: Kernell density plots size. Regime types based on Geddes et al/Anckar data categorization
twoway (kdensity v2regsupgroupssize if spart==1, lcolor(green) lwidth(medium) lpattern(longdash)) (kdensity v2regsupgroupssize if military==1, lcolor(orange) lwidth(medium) lpattern(solid)) (kdensity v2regsupgroupssize if personal==1, lcolor(brown) lwidth(medium) lpattern(dash)) (kdensity v2regsupgroupssize if monarchy==1, lcolor(blue) lwidth(medium) lpattern(dot)), ytitle(Density) xtitle(Regime support group size) xscale(range(-4 4)) xscale(noextend nofextend) xlabel(-4(2)4) title(Kernell density by autocracy type (green: dom.party; orange: military; blue: monarchy; brown: personalist), size(vsmall)) legend(off) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\ogsizebyGeddes.gph"


twoway (kdensity v2regoppgroupssize if spart==1, lcolor(green) lwidth(medium) lpattern(longdash)) (kdensity v2regoppgroupssize if military==1, lcolor(orange) lwidth(medium) lpattern(solid)) (kdensity v2regoppgroupssize if personal==1, lcolor(brown) lwidth(medium) lpattern(dash)) (kdensity v2regoppgroupssize if monarchy==1, lcolor(blue) lwidth(medium) lpattern(dot)), ytitle(Density) xtitle(Regime opposition group size) xscale(range(-4 4)) xscale(noextend nofextend) xlabel(-4(2)4) title(Kernell density by autocracy type (green: dom.party; orange: military; blue: monarchy; brown: personalist), size(vsmall)) legend(off) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\sgsizebyGeddes.gph"


** Figure 5 Global averages size measure over time
**Constructing separate dataset for global averages
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur  e_regionpol_6C

*Top plot
collapse v2regsupgroupssize v2regoppgroupssize no_groups no_oppgroups, by(year )
twoway (line v2regsupgroupssize year, sort lcolor(black) lpattern(longdash)) (line v2regoppgroupssize year, sort lcolor(green) lpattern(solid)), xline(1900) legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeansizegroups.gph"
**Edit by using gs12 instead of green, and fixing labels, etc. then saving as globalmeannogroups_ed.gph

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur  e_regionpol_6C

*Bottom plot (by regime type)
collapse v2regsupgroupssize v2regoppgroupssize no_groups no_oppgroups, by(year democracy63)
twoway (line v2regsupgroupssize year if democracy63==1, sort lcolor(black) lpattern(longdash)) (line v2regoppgroupssize year if democracy63==1, sort lcolor(black) lpattern(solid)) (line v2regsupgroupssize year if democracy63==0, sort lcolor(green) lpattern(longdash)) (line v2regoppgroupssize year if democracy63==0, sort lcolor(green) lpattern(solid)), xline(1900) legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeansizegroupsbyregime.gph"
**Edit by using gs12 instead of green, then saving as globalmeansizegroupsbyregime_ed.gph

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear


** Figure 6: Share of regimes, globally, with group included in the support coalition

keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur e_regionpol_6C


collapse v2regsupgroups_* v2regoppgroups_*, by(year)

label variable v2regsupgroups_0_diko "Aristocracy"
label variable v2regsupgroups_1_diko "Agrarian elites"
label variable v2regsupgroups_2_diko "Party elites"
label variable v2regsupgroups_3_diko "Business elites"
label variable v2regsupgroups_4_diko "The state bureacracy"
label variable v2regsupgroups_5_diko "The military"
label variable v2regsupgroups_6_diko "Ethnic/racial group"
label variable v2regsupgroups_7_diko "Religious group"
label variable v2regsupgroups_8_diko "Local elites"
label variable v2regsupgroups_9_diko "Urban working classes"
label variable v2regsupgroups_10_diko "Urban middle classes"
label variable v2regsupgroups_11_diko "Rural working classes"
label variable v2regsupgroups_12_diko "Rural middle classes"
label variable v2regsupgroups_13_diko "Foreign government"

label variable v2regsupgroups_0 "Aristocracy"
label variable v2regsupgroups_1 "Agrarian elites"
label variable v2regsupgroups_2 "Party elites"
label variable v2regsupgroups_3 "Business elites"
label variable v2regsupgroups_4 "The state bureacracy"
label variable v2regsupgroups_5 "The military"
label variable v2regsupgroups_6 "Ethnic/racial group"
label variable v2regsupgroups_7 "Religious group"
label variable v2regsupgroups_8 "Local elites"
label variable v2regsupgroups_9 "Urban working classes"
label variable v2regsupgroups_10 "Urban middle classes"
label variable v2regsupgroups_11 "Rural working classes"
label variable v2regsupgroups_12 "Rural middle classes"
label variable v2regsupgroups_13 "Foreign government"

label variable v2regoppgroups_0 "Aristocracy"
label variable v2regoppgroups_1 "Agrarian elites"
label variable v2regoppgroups_2 "Party elites"
label variable v2regoppgroups_3 "Business elites"
label variable v2regoppgroups_4 "The state bureacracy"
label variable v2regoppgroups_5 "The military"
label variable v2regoppgroups_6 "Ethnic/racial group"
label variable v2regoppgroups_7 "Religious group"
label variable v2regoppgroups_8 "Local elites"
label variable v2regoppgroups_9 "Urban working classes"
label variable v2regoppgroups_10 "Urban middle classes"
label variable v2regoppgroups_11 "Rural working classes"
label variable v2regoppgroups_12 "Rural middle classes"
label variable v2regoppgroups_13 "Foreign government"


*twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)), tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
*graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_ed.gph"
twoway (tsline v2regsupgroups_0_diko, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1_diko, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9_diko, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10_diko, lcolor(gs12) lpattern(dash)), tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_dichotomized_ed.gph"

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear



******************************************
*********** Appendix materials************
******************************************

************************************************************************************************************
** Appendix II: Regression results for country-year- and country-year-coder level reliability assessments **
************************************************************************************************************

** Table A.1
reg v2regsupgroupssize_sd v2regsupgroupssize_n nv2regsupgroupssize year historical i.e_regionpol_6C, cluster(country_id)
estimates store a
reg v2regsupgroupssize_sd v2regsupgroupssize_n nv2regsupgroupssize nv2regsupgroupssizesq year historical i.e_regionpol_6C, cluster(country_id)
estimates store b
reg v2regsupgroupssize_sd v2regsupgroupssize_n nv2regsupgroupssize nv2regsupgroupssizesq year historical i.e_regionpol_6C lnFarGDPpc nv2clrspct v2x_freexp_altinf lnpope, cluster(country_id)
estimates store c
reg v2regsupgroupssize_sd v2regsupgroupssize_n nv2regsupgroupssize nv2regsupgroupssizesq year historical i.e_regionpol_6C lnFarGDPpc nv2clrspct v2x_freexp_altinf lnpope democracy63, cluster(country_id)
estimates store d
estout a b c d, cells(b(star fmt(%9.2f)) t(par fmt(%9.2f))) rename(s_mil_loggdp Ln_GDP_pc s_bmr_democracy BMR_regime v2clrspct Impartial_public_admin s_bmr_democracy_trans BMR_democratic_transition v2x_Polyarchy Polyarchy) starlevels (* 0.05 ** 0.01) stats (N r2 N_g g_max)style (fixed)

xi: pwcorr v2regsupgroupssize_sd v2regsupgroupssize_n nv2regsupgroupssize nv2regsupgroupssizesq year historical i.e_regionpol_6C lnFarGDPpc nv2clrspct v2x_freexp_altinf lnpope democracy63
regress v2regsupgroupssize_sd lnpope
regress v2regsupgroupssize_sd lnpope v2regsupgroupssize_n 

** Table A.2: See separate replication code file for coder-level analysis


**************************************************************************************************************************************
** Appendix III: Validating our support group measures with measures on the social and occupational background of cabinet ministers. **
**************************************************************************************************************************************


**Calculating correlations for Figure A1 (scores used to draw figure in Excel)
**Correlations every fifth year
*Military  (around 50 observations)
correlate share_military v2regsupgroups_5 if year==1970
correlate share_military v2regsupgroups_5 if year==1975
correlate share_military v2regsupgroups_5 if year==1980
correlate share_military v2regsupgroups_5 if year==1985
correlate share_military v2regsupgroups_5 if year==1990
correlate share_military v2regsupgroups_5 if year==1995
correlate share_military v2regsupgroups_5 if year==2000
correlate share_military v2regsupgroups_5 if year==2005
correlate share_military v2regsupgroups_5 if year==2010
correlate share_military v2regsupgroups_5 if year==2015
correlate share_military v2regsupgroups_5 if year==2020
correlate share_military v2regsupgroups_5 
correlate share_military v2regsupgroups_5 if democracy63==0
correlate share_military v2regsupgroups_5 if democracy63==1


**Middle classes
generate supp_midd = (v2regsupgroups_10 +v2regsupgroups_12)/2 

correlate share_mid supp_mid if year==1970
correlate share_mid supp_mid if year==1975
correlate share_mid supp_mid if year==1980
correlate share_mid supp_mid if year==1985
correlate share_mid supp_mid if year==1990
correlate share_mid supp_mid if year==1995
correlate share_mid supp_mid if year==2000
correlate share_mid supp_mid if year==2005
correlate share_mid supp_mid if year==2010
correlate share_mid supp_mid if year==2015
correlate share_mid supp_mid if year==2020
correlate share_mid supp_mid
correlate share_mid supp_mid if democracy63==0
correlate share_mid supp_mid  if democracy63==1


** Working classes
generate supp_low=(v2regsupgroups_9 +v2regsupgroups_11)/2 

correlate share_low supp_low if year==1970
correlate share_low supp_low if year==1975
correlate share_low supp_low if year==1980
correlate share_low supp_low if year==1985
correlate share_low supp_low if year==1990
correlate share_low supp_low if year==1995
correlate share_low supp_low if year==2000
correlate share_low supp_low if year==2005
correlate share_low supp_low if year==2010
correlate share_low supp_low if year==2015
correlate share_low supp_low if year==2020
correlate share_low supp_low 
correlate share_low supp_low  if democracy63==0
correlate share_low supp_low  if democracy63==1


*********************************************************************************************************
** Appendix IV: Assessing between- and within variance for GWF regime units and CHISOLS leader groups. **
*********************************************************************************************************
xtset country_id year
sort country_id year


**Geddes et al analysis

*drop countreg nrregimes
generate countreg =1
replace countreg =. if gwf_casename==gwf_casename[_n-1] 
replace countreg =. if gwf_casename=="" 					
generate nrregimes =sum(countreg) 			
sort country_id year
replace nrregimes =. if gwf_casename=="" 

drop if nrregimes==.
xtset nrregimes year
sort nrregimes year 

generate firstlastyearregime = countreg
replace firstlastyearregime =1 if countreg[_n+1]==1 

xtsum no_groups
xtsum no_groups if firstlastyearregime!=1

**Table A3 numbers
**Within and between regime variance
xtsum no_groups v2regsupgroupssize v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13
**Within and between country variance
xtset country_id year
sort country_id year
xtsum no_groups v2regsupgroupssize v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13


**Analysis only reported in text: Pure vs Hybrid regimes
tabulate gwf_regimetype
xtset nrregimes year
sort nrregimes year 

xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if puremil==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if purepar==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if puremaxgwf==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if mipa==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if mipe==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if pepa==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if mipepa==1
xtsum no_groups v2regsupgroupssize v2regsupgroups_2 v2regsupgroups_5 v2regsupgroups_2_diko v2regsupgroups_5_diko if hybridgwf==1

xtset country_id year
sort country_id year


**SOLS analysis
use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
*solschdum: Coded 1 if there is at least one SOLS change that lasts longer than 30 days in theyear, and 0 otherwise. This variable does not take into account minor SOLS changes, nor SOLS changes that last less than 30 days.
browse country_id year solschdum
generate solsstart =solschdum
by country_id, sort: replace solsstart =1 if solschdum==0 & solschdum[_n-1]==.
sort country_id year
generate nrsols =sum(solsstart) 
replace nrsols=. if solsstart==.	

sort nrsols year
drop if nrsols==.

**Table A4 numbers
**Within and between regime variance
xtset nrsols year
xtsum no_groups v2regsupgroupssize v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13
**Within and between country variance
xtset country_id year
xtsum no_groups v2regsupgroupssize v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13

xtset country_id year
sort country_id year

**Between and within HRD regime variance for democracies and autocracies
use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
**With vs between regime variation check for HRD
sort v2regidnr year
drop if v2regidnr==.
xtset v2regidnr year

** Table A5 numbers
xtsum no_groups v2regsupgroupssize 
xtsum no_groups v2regsupgroupssize  if democracy63==0
xtsum no_groups v2regsupgroupssize  if democracy63==1
generate hrdduration = v2regdur/365
xtsum no_groups v2regsupgroupssize if democracy63==1 & hrdduration>49.9999


use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
xtset country_id year
sort country_id year
************************************************************************
** Appendix VI: Additional figures displaying descriptive statistics. **
************************************************************************


** Appendix Figure A2
*histogram nr_v2regsuppgroups, discrete percent fcolor(black) lwidth(none) ytitle(Percent of coded country-year observations) xtitle(Number of country experts coding) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))
histogram nr_v2regsuppgroups if year>1899, discrete percent fcolor(black) lwidth(none) ytitle(Percent of coded country-year observations) xtitle(Number of country experts coding) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))
histogram nr_v2regoppgroups, discrete percent fcolor(black) lwidth(none) ytitle(Percent of coded country-year observations) xtitle(Number of country experts coding) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white))

** Appendix Figure A3
histogram no_groups, discrete width(1) percent by(democracy63, style(compact) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Nr_supp_groups_hist.gph"

histogram no_oppgroups, discrete width(1) percent by(democracy63, style(compact) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Nr_opp_groups_hist.gph"


** Appendix Figure A4
collapse v2regsupgroupssize v2regoppgroupssize no_groups no_oppgroups, by(year democracy63)

twoway (line no_groups year if democracy63==1, sort lcolor(black) lpattern(longdash)) (line no_oppgroups year if democracy63==1, sort lcolor(black) lpattern(solid)) (line no_groups year if democracy63==0, sort lcolor(green) lpattern(longdash)) (line no_oppgroups year if democracy63==0, sort lcolor(green) lpattern(solid)), xline(1900) legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeannogroupsbyregime.gph"

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear

** Appendix Figure A5
graph bar, over(v2regimpgroup) by(, legend(off)) by(, graphregion(margin(small) fcolor(white) ifcolor(white)) plotregion(margin(small) fcolor(white) ifcolor(white))) by(democracy63)
**some editing and then save
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Barchartsupport.gph"

** Appendix Figure A6
graph bar, over(v2regimpoppgroup) by(, legend(off)) by(, graphregion(margin(small) fcolor(white) ifcolor(white)) plotregion(margin(small) fcolor(white) ifcolor(white))) by(democracy63)
**some editing and then save
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Barchartoppo.gph"


** Appendix Figure A7:

collapse v2regsupgroups_* v2regoppgroups_*, by(year)

label variable v2regsupgroups_0_diko "Aristocracy"
label variable v2regsupgroups_1_diko "Agrarian elites"
label variable v2regsupgroups_2_diko "Party elites"
label variable v2regsupgroups_3_diko "Business elites"
label variable v2regsupgroups_4_diko "The state bureacracy"
label variable v2regsupgroups_5_diko "The military"
label variable v2regsupgroups_6_diko "Ethnic/racial group"
label variable v2regsupgroups_7_diko "Religious group"
label variable v2regsupgroups_8_diko "Local elites"
label variable v2regsupgroups_9_diko "Urban working classes"
label variable v2regsupgroups_10_diko "Urban middle classes"
label variable v2regsupgroups_11_diko "Rural working classes"
label variable v2regsupgroups_12_diko "Rural middle classes"
label variable v2regsupgroups_13_diko "Foreign government"

label variable v2regsupgroups_0 "Aristocracy"
label variable v2regsupgroups_1 "Agrarian elites"
label variable v2regsupgroups_2 "Party elites"
label variable v2regsupgroups_3 "Business elites"
label variable v2regsupgroups_4 "The state bureacracy"
label variable v2regsupgroups_5 "The military"
label variable v2regsupgroups_6 "Ethnic/racial group"
label variable v2regsupgroups_7 "Religious group"
label variable v2regsupgroups_8 "Local elites"
label variable v2regsupgroups_9 "Urban working classes"
label variable v2regsupgroups_10 "Urban middle classes"
label variable v2regsupgroups_11 "Rural working classes"
label variable v2regsupgroups_12 "Rural middle classes"
label variable v2regsupgroups_13 "Foreign government"

label variable v2regoppgroups_0 "Aristocracy"
label variable v2regoppgroups_1 "Agrarian elites"
label variable v2regoppgroups_2 "Party elites"
label variable v2regoppgroups_3 "Business elites"
label variable v2regoppgroups_4 "The state bureacracy"
label variable v2regoppgroups_5 "The military"
label variable v2regoppgroups_6 "Ethnic/racial group"
label variable v2regoppgroups_7 "Religious group"
label variable v2regoppgroups_8 "Local elites"
label variable v2regoppgroups_9 "Urban working classes"
label variable v2regoppgroups_10 "Urban middle classes"
label variable v2regoppgroups_11 "Rural working classes"
label variable v2regoppgroups_12 "Rural middle classes"
label variable v2regoppgroups_13 "Foreign government"


twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)), tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_ed.gph"

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear

** Appendix Figures A9-A13

keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur  e_regionpol_6C

collapse v2regsupgroups_* v2regoppgroups_*, by(year e_regionpol_6C)

label variable v2regsupgroups_0_diko "Aristocracy"
label variable v2regsupgroups_1_diko "Agrarian elites"
label variable v2regsupgroups_2_diko "Party elites"
label variable v2regsupgroups_3_diko "Business elites"
label variable v2regsupgroups_4_diko "The state bureacracy"
label variable v2regsupgroups_5_diko "The military"
label variable v2regsupgroups_6_diko "Ethnic/racial group"
label variable v2regsupgroups_7_diko "Religious group"
label variable v2regsupgroups_8_diko "Local elites"
label variable v2regsupgroups_9_diko "Urban working classes"
label variable v2regsupgroups_10_diko "Urban middle classes"
label variable v2regsupgroups_11_diko "Rural working classes"
label variable v2regsupgroups_12_diko "Rural middle classes"
label variable v2regsupgroups_13_diko "Foreign government"

label variable v2regsupgroups_0 "Aristocracy"
label variable v2regsupgroups_1 "Agrarian elites"
label variable v2regsupgroups_2 "Party elites"
label variable v2regsupgroups_3 "Business elites"
label variable v2regsupgroups_4 "The state bureacracy"
label variable v2regsupgroups_5 "The military"
label variable v2regsupgroups_6 "Ethnic/racial group"
label variable v2regsupgroups_7 "Religious group"
label variable v2regsupgroups_8 "Local elites"
label variable v2regsupgroups_9 "Urban working classes"
label variable v2regsupgroups_10 "Urban middle classes"
label variable v2regsupgroups_11 "Rural working classes"
label variable v2regsupgroups_12 "Rural middle classes"
label variable v2regsupgroups_13 "Foreign government"

label variable v2regoppgroups_0 "Aristocracy"
label variable v2regoppgroups_1 "Agrarian elites"
label variable v2regoppgroups_2 "Party elites"
label variable v2regoppgroups_3 "Business elites"
label variable v2regoppgroups_4 "The state bureacracy"
label variable v2regoppgroups_5 "The military"
label variable v2regoppgroups_6 "Ethnic/racial group"
label variable v2regoppgroups_7 "Religious group"
label variable v2regoppgroups_8 "Local elites"
label variable v2regoppgroups_9 "Urban working classes"
label variable v2regoppgroups_10 "Urban middle classes"
label variable v2regoppgroups_11 "Rural working classes"
label variable v2regoppgroups_12 "Rural middle classes"
label variable v2regoppgroups_13 "Foreign government"


twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)) if e_regionpol_6C==5, tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)) if e_regionpol_6C==2, tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)) if e_regionpol_6C==1, tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)) if e_regionpol_6C==6, tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)) if e_regionpol_6C==3, tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)) if e_regionpol_6C==4, tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear

************************************************************************************
** Appendix VII: Sensitivity to altering cut-off for regime support group dummies **
************************************************************************************


** Table A6
correlate v2regsupgroups_0_diko v2regsupgroups_0_diko40 v2regsupgroups_0_diko45 v2regsupgroups_0_diko55 v2regsupgroups_0_diko60
correlate v2regsupgroups_1_diko v2regsupgroups_1_diko40 v2regsupgroups_1_diko45 v2regsupgroups_1_diko55 v2regsupgroups_1_diko60
correlate v2regsupgroups_2_diko v2regsupgroups_2_diko40 v2regsupgroups_2_diko45 v2regsupgroups_2_diko55 v2regsupgroups_2_diko60
correlate v2regsupgroups_3_diko v2regsupgroups_3_diko40 v2regsupgroups_3_diko45 v2regsupgroups_3_diko55 v2regsupgroups_3_diko60
correlate v2regsupgroups_4_diko v2regsupgroups_4_diko40 v2regsupgroups_4_diko45 v2regsupgroups_4_diko55 v2regsupgroups_4_diko60
correlate v2regsupgroups_5_diko v2regsupgroups_5_diko40 v2regsupgroups_5_diko45 v2regsupgroups_5_diko55 v2regsupgroups_5_diko60
correlate v2regsupgroups_6_diko v2regsupgroups_6_diko40 v2regsupgroups_6_diko45 v2regsupgroups_6_diko55 v2regsupgroups_6_diko60
correlate v2regsupgroups_7_diko v2regsupgroups_7_diko40 v2regsupgroups_7_diko45 v2regsupgroups_7_diko55 v2regsupgroups_7_diko60
correlate v2regsupgroups_8_diko v2regsupgroups_8_diko40 v2regsupgroups_8_diko45 v2regsupgroups_8_diko55 v2regsupgroups_8_diko60
correlate v2regsupgroups_9_diko v2regsupgroups_9_diko40 v2regsupgroups_9_diko45 v2regsupgroups_9_diko55 v2regsupgroups_9_diko60
correlate v2regsupgroups_10_diko v2regsupgroups_10_diko40 v2regsupgroups_10_diko45 v2regsupgroups_10_diko55 v2regsupgroups_10_diko60
correlate v2regsupgroups_11_diko v2regsupgroups_11_diko40 v2regsupgroups_11_diko45 v2regsupgroups_11_diko55 v2regsupgroups_11_diko60
correlate v2regsupgroups_12_diko v2regsupgroups_12_diko40 v2regsupgroups_12_diko45 v2regsupgroups_12_diko55 v2regsupgroups_12_diko60
correlate v2regsupgroups_13_diko v2regsupgroups_13_diko40 v2regsupgroups_13_diko45 v2regsupgroups_13_diko55 v2regsupgroups_13_diko60
correlate no_groups no_groups40 no_groups45 no_groups55 no_groups60


use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur e_regionpol_6C

collapse v2regsupgroups_* v2regoppgroups_*, by(year)


** Figure A.14 (bottom)
twoway (tsline v2regsupgroups_0_diko40, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1_diko40, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9_diko40, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10_diko40, lcolor(gs12) lpattern(dash)), tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_dichotomized_ed40.gph"
** Figure A.14 (middle)
twoway (tsline v2regsupgroups_0_diko, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1_diko, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9_diko, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10_diko, lcolor(gs12) lpattern(dash)), tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_dichotomized_ed.gph"
** Figure A.14 (top)
twoway (tsline v2regsupgroups_0_diko60, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1_diko60, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9_diko60, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10_diko60, lcolor(gs12) lpattern(dash)), tline(1900, lcolor(black)) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_dichotomized_ed60.gph"

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear




*************************************************************************
** Appendix VIII: Sensitivity to omitting observations with few coders **
*************************************************************************

**Re-generating graphs for >3 coders >3

*First post-1900 grah all coders
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur e_regionpol_6C

drop if year<1900

collapse v2regsupgroups_* v2regoppgroups_*, by(year)

label variable v2regsupgroups_0_diko "Aristocracy"
label variable v2regsupgroups_1_diko "Agrarian elites"
label variable v2regsupgroups_2_diko "Party elites"
label variable v2regsupgroups_3_diko "Business elites"
label variable v2regsupgroups_4_diko "The state bureacracy"
label variable v2regsupgroups_5_diko "The military"
label variable v2regsupgroups_6_diko "Ethnic/racial group"
label variable v2regsupgroups_7_diko "Religious group"
label variable v2regsupgroups_8_diko "Local elites"
label variable v2regsupgroups_9_diko "Urban working classes"
label variable v2regsupgroups_10_diko "Urban middle classes"
label variable v2regsupgroups_11_diko "Rural working classes"
label variable v2regsupgroups_12_diko "Rural middle classes"
label variable v2regsupgroups_13_diko "Foreign government"

** Appendix Figure A.15 (top)
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)), graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_post1900.gph", replace

* Now for 4 or more coders
use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur e_regionpol_6C

drop if year<1900
drop if v2regsupgroupssize_nr<4

collapse v2regsupgroups_* v2regoppgroups_*, by(year)

label variable v2regsupgroups_0_diko "Aristocracy"
label variable v2regsupgroups_1_diko "Agrarian elites"
label variable v2regsupgroups_2_diko "Party elites"
label variable v2regsupgroups_3_diko "Business elites"
label variable v2regsupgroups_4_diko "The state bureacracy"
label variable v2regsupgroups_5_diko "The military"
label variable v2regsupgroups_6_diko "Ethnic/racial group"
label variable v2regsupgroups_7_diko "Religious group"
label variable v2regsupgroups_8_diko "Local elites"
label variable v2regsupgroups_9_diko "Urban working classes"
label variable v2regsupgroups_10_diko "Urban middle classes"
label variable v2regsupgroups_11_diko "Rural working classes"
label variable v2regsupgroups_12_diko "Rural middle classes"
label variable v2regsupgroups_13_diko "Foreign government"

** Appendix Figure A.15 (bottom)
twoway (tsline v2regsupgroups_0, lcolor(black) lpattern(solid)) (tsline v2regsupgroups_1, lcolor(ltblue) lpattern(solid)) (tsline v2regsupgroups_9, lcolor(orange) lpattern(dash)) (tsline v2regsupgroups_10, lcolor(gs12) lpattern(dash)), graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\groups_In_supp_coal_glob_4coders.gph", replace


use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur  e_regionpol_6C

drop if year<1900

collapse v2regsupgroupssize v2regoppgroupssize no_groups no_oppgroups, by(year democracy63)

** Appendix Figure A.16 (top)
twoway (line v2regsupgroupssize year if democracy63==1, sort lcolor(black) lpattern(longdash))  (line v2regsupgroupssize year if democracy63==0, sort lcolor(gs12) lpattern(longdash)), legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeansizegroupsbyregimepost1900.gph"

** Appendix Figure A.17 (top)
twoway (line v2regoppgroupssize year if democracy63==1, sort lcolor(black) lpattern(solid)) (line v2regoppgroupssize year if democracy63==0, sort lcolor(gs12) lpattern(solid)), legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeansizegroupsbyregimeoppopost1900.gph"

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur  e_regionpol_6C

drop if year<1900
drop if v2regsupgroupssize_nr<4

collapse v2regsupgroupssize v2regoppgroupssize no_groups no_oppgroups, by(year democracy63)

** Appendix Figure A.16 (bottom)
twoway (line v2regsupgroupssize year if democracy63==1, sort lcolor(black) lpattern(longdash))  (line v2regsupgroupssize year if democracy63==0, sort lcolor(gs12) lpattern(longdash)), legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeansizegroupsbyregimelessfour.gph"

use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
keep country_id year s_far_Maddison_pop_estimate s_far_Maddison_gdppc_1990_estima democracy63 v2x_polyarchy v2reginfo v2regendtype v2regint v2regimpgroup v2regsupgroupssize v2regsuploc v2regimpoppgroup v2regoppgroupssize v2regopploc v2regproreg v2regantireg v2regpower v2regendtypems_0 v2regendtypems_1 v2regendtypems_2 v2regendtypems_3 v2regendtypems_4 v2regendtypems_5 v2regendtypems_6 v2regendtypems_7 v2regendtypems_8 v2regendtypems_9 v2regendtypems_10 v2regendtypems_11 v2regendtypems_12 v2regendtypems_13 v2regoppgroups_0 v2regoppgroups_1 v2regoppgroups_2 v2regoppgroups_3 v2regoppgroups_4 v2regoppgroups_5 v2regoppgroups_6 v2regoppgroups_7 v2regoppgroups_8 v2regoppgroups_9 v2regoppgroups_10 v2regoppgroups_11 v2regoppgroups_12 v2regoppgroups_13 v2regoppgroupsact_0 v2regoppgroupsact_1 v2regoppgroupsact_2 v2regoppgroupsact_3 v2regoppgroupsact_4 v2regoppgroupsact_5 v2regoppgroupsact_6 v2regoppgroupsact_7 v2regoppgroupsact_8 v2regoppgroupsact_9 v2regoppgroupsact_10 v2regoppgroupsact_11 v2regoppgroupsact_12 v2regoppgroupsact_13 v2regsupgroups_0 v2regsupgroups_1 v2regsupgroups_2 v2regsupgroups_3 v2regsupgroups_4 v2regsupgroups_5 v2regsupgroups_6 v2regsupgroups_7 v2regsupgroups_8 v2regsupgroups_9 v2regsupgroups_10 v2regsupgroups_11 v2regsupgroups_12 v2regsupgroups_13 v2regsupgroups* v2regoppgroups* no_groups no_oppgroups breakdown v2regidnr v2regdur  e_regionpol_6C

drop if year<1900
drop if v2regoppgroupssize_nr <4

collapse v2regsupgroupssize v2regoppgroupssize no_groups no_oppgroups, by(year democracy63)

** Appendix Figure A.17 (bottom)
twoway (line v2regoppgroupssize year if democracy63==1, sort lcolor(black) lpattern(solid)) (line v2regoppgroupssize year if democracy63==0, sort lcolor(gs12) lpattern(solid)), legend(region(lwidth(none))) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\globalmeansizegroupsbyregimeoppolessfour.gph"


use "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\BJPS RR\Replication_CY_data.dta", clear
** Appendix Figure A.18 (top)
histogram no_groups if year>1900, discrete width(1) percent by(democracy63, style(compact) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Nr_supp_groups_histpost1900.gph"

** Appendix Figure A.18 (bottom)
histogram no_groups if year>1900 & v2regsupgroupssize_nr>3, discrete width(1) percent by(democracy63, style(compact) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Nr_supp_groups_histfour.gph"

** Appendix Figure A.19 (top)
histogram no_oppgroups if year>1900, discrete width(1) percent by(democracy63, style(compact) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Nr_opp_groups_histpost1900.gph"

** Appendix Figure A.19 (bottom)
histogram no_oppgroups if year>1900 & v2regoppgroupssize_nr >3, discrete width(1) percent by(democracy63, style(compact) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Nr_opp_groups_histfour.gph"




********************************************************************************************************************************
** Appendix IX: Sensitivity of Regime support group measures to leaving out one expert coder at the time from the aggregation **
********************************************************************************************************************************
**See separate do file for coder level analysis


******************************************************************************************************
** Appendix X: Country-case examples: Regime support groups size and Regime support groups dummies  **
******************************************************************************************************

*regime names and dates for the three countries
browse  v2reginfo if v2reginfo!=v2reginfo[_n-1] & country_name=="Egypt"
browse  v2reginfo if v2reginfo!=v2reginfo[_n-1] & country_name=="France"
browse  v2reginfo if v2reginfo!=v2reginfo[_n-1] & country_name=="Spain"



** Appendix Figure A.20
xtline v2regsupgroupssize if country_id==13, i(country_name) t(year) ylabel(-1(1)2) tline(1798 1801 1803 1805 1866 1878 1879 1881 1882 1914 1922 1928 1930 1935 1942 1944 1952 1953 2011 2012 2013 2014) subtitle(, nobox) byopts(legend(off)) byopts(graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Egypt_size.gph", replace

** Appendix Figure A.21
xtline v2regsupgroupssize if country_id==76, i(country_name) t(year) ylabel(-1(1)3) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) subtitle(, nobox) byopts(legend(off)) byopts(graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\France_size.gph", replace

** Appendix Figure A.22
*France 1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959
browse country_name year v2reginfo country_id if country_name=="France"
twoway (tsline v2regsupgroups_0_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr0.gph", replace
twoway (tsline v2regsupgroups_1_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr1", replace
twoway (tsline v2regsupgroups_2_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr2", replace
twoway (tsline v2regsupgroups_3_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr3", replace
twoway (tsline v2regsupgroups_4_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr4", replace
twoway (tsline v2regsupgroups_5_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr5", replace
twoway (tsline v2regsupgroups_6_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr6", replace
twoway (tsline v2regsupgroups_7_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr7", replace
twoway (tsline v2regsupgroups_8_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr8", replace
twoway (tsline v2regsupgroups_9_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr9", replace
twoway (tsline v2regsupgroups_10_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr10", replace
twoway (tsline v2regsupgroups_11_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr11", replace
twoway (tsline v2regsupgroups_12_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr12", replace
twoway (tsline v2regsupgroups_13_diko if country_id==76  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1792 1799 1804 1815 1830 1848 1851 1870 1940 1944 1959) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr13", replace

graph combine "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr13.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr12.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr11.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr10.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr9.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr8.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr7.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr6.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr5.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr4.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr3.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr2.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr1.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Fr0.gph", xcommon cols(3) graphregion(margin(small) fcolor(white) ifcolor(white))

graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Comb_France.gph", replace

** Appendix Figure A.23
xtline v2regsupgroupssize if country_id==96, i(country_name) t(year) ylabel(-1(1)3) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) subtitle(, nobox) byopts(legend(off)) byopts(graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white)))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Spain_size.gph", replace

** Appendix Figure A.24
*Spain 1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 
browse country_name year v2reginfo country_id if country_name=="Spain"
twoway (tsline v2regsupgroups_0_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S0.gph", replace
twoway (tsline v2regsupgroups_1_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S1", replace
twoway (tsline v2regsupgroups_2_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S2", replace
twoway (tsline v2regsupgroups_3_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S3", replace
twoway (tsline v2regsupgroups_4_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S4", replace
twoway (tsline v2regsupgroups_5_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S5", replace
twoway (tsline v2regsupgroups_6_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S6", replace
twoway (tsline v2regsupgroups_7_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S7", replace
twoway (tsline v2regsupgroups_8_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S8", replace
twoway (tsline v2regsupgroups_9_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S9", replace
twoway (tsline v2regsupgroups_10_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S10", replace
twoway (tsline v2regsupgroups_11_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S11", replace
twoway (tsline v2regsupgroups_12_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S12", replace
twoway (tsline v2regsupgroups_13_diko if country_id==96  & inrange(year, 1789, 2020), recast(bar)), ylabel(0(1)1) xscale(range(1789 2020)) xlabel(1800(50)2000) tline(1808 1813 1820 1823 1833 1837 1840 1843 1845 1854 1868 1869 1873 1874 1876 1923 1931 1939 1975 1978 ) graphregion(fcolor(white) ifcolor(white))
graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S13", replace

graph combine "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S13.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S12.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S11.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S10.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S9.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S8.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S7.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S6.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S5.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S4.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S3.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S2.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S1.gph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\S0.gph", xcommon cols(3) graphregion(margin(small) fcolor(white) ifcolor(white))

graph save "Graph" "C:\Users\carlhk\Dropbox\Supportcoal_datapaper\v12figures\Comb_Spain.gph", replace


